<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改数据库配置')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-post-edit" th:object="${dbconfig}">
		<input id="postId" name="id" type="hidden" th:field="*{id}"/>
		<div class="form-group">
			<label class="col-sm-3 control-label is-required">connectName：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="connectName" id="connectName" th:field="*{connectName}" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label is-required">type：</label>
			<div class="col-sm-8">
				<select class="form-control"  name="type" id="type" th:field="*{type}" required>
					<option value="">--请选择数据库类型--</option>
					<option th:each="typeList:${dbtypes}" th:value="${typeList}" th:text="${typeList}"></option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label is-required">url：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="url" id="url" th:field="*{url}" required>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label is-required">userName：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="userName" id="userName" th:field="*{userName}" required>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label is-required">pwd：</label>
			<div class="col-sm-8">
				<input class="form-control" type="password" name="pwd" id="pwd" th:value="*{pwd}" required>
			</div>
		</div>
	</form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
	var prefix = ctx + "system/dbconfig";

	$("#form-post-edit").validate({
		onkeyup: false,
		rules:{
			connectName:{
				remote: {
					url: ctx + "system/dbconfig/checkConnectNameUnique",
					type: "post",
					dataType: "json",
					data: {
						"connectName": function() {
							return $("input[name='connectName']").val();
						}
					},
					dataFilter: function(data, type) {
						return $.validate.unique(data);
					}
				}
			},
		},
		messages: {
			"connectName": {
				remote: "connectName已经存在"
			}
		},
		focusCleanup: true
	});

	function submitHandler() {
		if ($.validate.form()) {
			$.operate.save(prefix + "/edit", $('#form-post-edit').serialize());
		}
	}
</script>
</body>
</html>